package com.d0320;

import java.io.*;

public class FileCopy {
    public static void main(String[] args) {
        FileInputStream fis=null;
        FileOutputStream fos=null;
        try {
            fis=new FileInputStream(new File("src/com/d0320/data.bin"));
            fos=new FileOutputStream(new File("src/com/d0320/data2.bin"));
            byte []buffer=new byte[1024];//定义一个数组
            int x=0;
            while((x=fis.read(buffer,0,buffer.length)) != -1){
                fos.write(buffer,0,x);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (null != fos) {
                try {
                    fos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (null != fis) {
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

